import React, { memo, useContext } from "react";

import { MyContext } from "./Reducer";

const T2 = memo(() => {
  let { state, dispatch } = useContext(MyContext);

  return (
    <div>
      我是 T2 {state.name} {state.age}
      <button
        onClick={(e) => {
          dispatch({
            type: "setName",
            name: "biubiu怪",
          });
        }}
      >
        setName
      </button>
      <button
        onClick={(e) => {
          dispatch({
            type: "setAge",
            name: "1000000",
          });
        }}
      >
        setAge
      </button>
    </div>
  );
});

export default T2;
